package cn.pconline.autoclub.entity;

import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;

/**
 *
 * @author wanganning
 */
@Entity(tableName = "ac_member_info",logChange = true)
public class ClubMember implements EntityWithUserProp,EntityWithClubProp {
    public final static int IS_VIP = 1; //认证会员
    public final static int NOT_VIP = 0 ;//普通会员
    @Id
    @Column(name = "id")
    private long id;
    @Column(name = "user_id")
    private long uid;
    @Column(name = "club_id")
    private long clubId;
    @Column(name = "join_at")
    private Date joinAt;
    @Column(name = "topic_count")
    private int topicCount;
    @Column(name = "petrol")
    private int petrol;
    @Column(name = "admin_type")
    private int adminType;
    @Column(name = "update_at")
    private Date updateAt;
    @Column(name = "rank")
    private int rank;
    @Column(name="remark_name")
    private String remarkName;
    public static final int ADMIN = 2;
    public static final int VICE_ADMIN = 1;
    public static final int NON_ADMIN = 0;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Override
    public long getUid() {
        return uid;
    }

    @Override
    public void setUid(long uid) {
        this.uid = uid;
    }

    public long getClubId() {
        return clubId;
    }

    public void setClubId(long clubId) {
        this.clubId = clubId;
    }

    public Date getJoinAt() {
        return joinAt;
    }

    public void setJoinAt(Date joinAt) {
        this.joinAt = joinAt;
    }

    public int getTopicCount() {
        return topicCount;
    }

    public void setTopicCount(int topicCount) {
        this.topicCount = topicCount;
    }

    public int getPetrol() {
        return petrol;
    }

    public void setPetrol(int petrol) {
        this.petrol = petrol;
    }

    public int getAdminType() {
        return adminType;
    }

    public void setAdminType(int adminType) {
        this.adminType = adminType;
    }

    public Date getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Date updateAt) {
        this.updateAt = updateAt;
    }
    /**
     * 是否会长
     * @return
     */
    public boolean isAdmin() {
        return adminType == ADMIN;
    }
    /**
     * 是否副会长
     * @return
     */
    public boolean isViceAdmin() {
        return adminType == VICE_ADMIN;
    }
    /**
     * 是否管理员
     * @return
     */
    public boolean isAdministrator(){
    	if(adminType == ADMIN || adminType == VICE_ADMIN){
    		return true;
    	}else{
    		return false;
    	}
    }
    @Transient(cache = false)
    private User user;
    @Transient(cache = false)
    private Club club;

    @Override
    public User getUser() {
        return user;
    }

    @Override
    public void setUser(User user) {
        this.user = user;
    }

    public Club getClub() {
        return club;
    }

    public void setClub(Club club) {
        this.club = club;
    }

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

    public String getRemarkName() {
        return remarkName;
    }

    public void setRemarkName(String remarkName) {
        this.remarkName = remarkName;
    }
        
    public JSONObject toJson(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("adminType", getAdminType());
        jsonObject.put("memberId", getId());     
        return jsonObject;    
    }
}
